<?php
/*

 select * from orders
where openid in (select openid from  orders group by openid having count(openid) > 1);


select openid from  orders group by openid having count(openid) > 1

 */
$userMember=array();
if (isset($_GET['id']) && '1' == $_GET['id']){
    include 'load.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $shareInfoData=array();
    $query=$mysqli->query("SELECT * FROM `orders` where isshot=9 limit 0,1  ");
    while ($list=$query->fetch_assoc()){
        
        $openid=$list['openid'];
        
        $queryU=$mysqli->query("SELECT * FROM `uinfo` where openid='".$openid."' limit 0,1 ");
        $getU=$queryU->fetch_assoc();
        if ('old' == $getU['isold']){
            var_dump($getU);
            echo $getU['isold'];
            //echo "<br />";
            $userMember[$getU['memberno']]=$getU['memberno'];
            $queryShare=$mysqli->query("SELECT * FROM `share` where openid='".$openid."' limit 0,5 ");
            
            while ($getShare=$queryShare->fetch_assoc()){
                $shareInfoData[]=$getShare['zuopenid'];
                var_dump($getShare);
                echo "<br />";
            }
        }
        
        
        
        
    }
    
    
    echo "<br />";
 
    foreach ($shareInfoData as $value){
        $queryU=$mysqli->query("SELECT * FROM `uinfo` where openid='".$value."' limit 0,1 ");
        $getU=$queryU->fetch_assoc();
        
        echo $getU['memberno'];
        echo "<br />";
        var_dump($getU);
        $userMember[$getU['memberno']]=$getU['memberno'];
        echo "<br /><br />";
    }
    
    foreach ($userMember as $v){
        echo $v;
        echo "<br />";
    }
 
}
echo "<br />"; 
$url='https://elixir.omnimkt.com/elixir07/web/order/?c=cron-order2';
?>
<?php if (count($userMember) > 2){ ?>
<a href="<?php echo $url ?>"><?php echo count($userMember) ?>.....................next ..........</a>
<br /><br /><br /><br />

<script>
window.setTimeout(function(){
	window.location.href="<?php echo $url; ?>";;
}, 2000);
</script>

<?php }else{  ?>
<script>
window.setTimeout(function(){
	window.location.href="https://elixir.omnimkt.com/elixir07/web/?c=selim2&id=1";;
}, 40000);
</script>
<?php    
    echo count($userMember);
}?>